﻿using Autofac;
using System.Reflection;

namespace J.M.Inventory.Write.API.MyWriteFac
{
    public class InventoryAutoFac : Autofac.Module
    {
        //autofac注入
        protected override void Load(ContainerBuilder builder)
        {

            var Repository = Assembly.Load("J.M.Inventory.Infrastruecure");
            var Services = Assembly.Load("J.M.Inventory.Application");
            builder.RegisterAssemblyTypes(Repository, Services)
                .Where(t => t.Name.EndsWith("Repository") || t.Name.EndsWith("Services"))
                .AsImplementedInterfaces()
                .InstancePerLifetimeScope();
        }
    }
}
